/**
 * Created by liujie on 2017/11/12.
 */
/**
 * Created by liujie on 2017/10/11.
 * 监控管理
 */
var express = require('express');
var request = require('request');
var Mock = require('mockjs');
var url = require('url');
var qstr = require("querystring");
var fs = require("fs");
var pro = require('../../property/cuspro');
var auth = require('../../auth/auth');
var util = require('../../util/commonutil');
var router = express.Router();
var resultJSON = require('../common/resultJSON');

router.get('/',function (req, res, next) {
    res.render("report/runreportManage");
});
//获取停车数据
router.post('/queryRunReportData',function (req,res,next) {
    var sid=auth.getSessionID(req, res, next);
    var qs=req.body;
    qs.sid = sid;
    if(qs.isSearch){
        request({
            url:pro.devServeraddr + "heb/report/runReportB",
            method: "POST",
            qs:qs
        },function (error, response, body) {
            console.log("停车报表数据>>"+body);
            var tableResult = {
                total:0,
                rows:[],
                isSuccess:true,//必须是boolean类型
                message:""
            };
            if(!error && response.statusCode == 200){
                var result = JSON.parse(body);
                if(result.success == true){
                    tableResult.isSuccess = true;
                    tableResult.total = result.total;
                    tableResult.rows = result.rows;
                }
            }else{
                tableResult.isSuccess = false;
                tableResult.message = "停车报表查询数据异常，请稍后重试！";
            }
            res.json(tableResult);
        });
    }else{
        var tableResult = {
            total:0,
            rows:[],
            isSuccess:true,//必须是boolean类型
            message:""
        };
        res.json(tableResult);
    }

});
module.exports =router;